﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CnGine.Comm;

public partial class admin_data : LoginBase
{
    protected void Page_Load(object sender, EventArgs e)
    {


        if (!IsPostBack)
        {
            BindData();
        }
    }

    public void BindData()
    {
        txtUserName.Text = base.User.UserName;
        txtRealName.Text = base.User.RealName;
        txtEmail.Text = base.User.Email;
        txtQQ.Text = base.User.QQ;
        txtCity.Text = base.User.AreaName;
        txtTel.Text = base.User.Tel;
        txtIntro.Text = base.User.Description;
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        Model.User u = new Model.User();
        u.RealName = txtRealName.Text.Trim();
        u.Email = txtEmail.Text.Trim().ToLower();
        u.QQ = txtQQ.Text.Trim();
        u.Tel = txtTel.Text.Trim();
        u.Description = txtIntro.Text.Trim();

        BLL.User b = new BLL.User();
        if (b.Update(u, "id=" + base.User.ID) > 0)
        {
            Model.User u1 = base.User;
            u1.RealName = u.RealName;
            u1.Email = u.Email;
            u1.QQ = u.QQ;
            u1.Tel = u.Tel;
            u1.Description = u.Description;

            base.User = u1;
            MessageBox.Alert("修改成功！", this.Page);
        }
        else
        {
            MessageBox.Alert("修改失败，请稍后重试！", this.Page);
        }
    }
}